/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	/// 
	/// module : levelLogic
	/// </summary>
	public class LevelNormalEntityPOD : IPOD 
    {
        public readonly static Func<LevelNormalEntityPOD> FACTORY = () => new LevelNormalEntityPOD();
		public static Func<LevelNormalEntityPOD> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        /// module config id - LevelEntityConfig
        /// </summary>
		public int mcid;
		/// <summary>
        /// 
        /// </summary>
        private List<ushort> m_tags;
		/// <summary>
        /// 
        /// </summary>
		public bool isObstacleActive;
		/// <summary>
        /// 
        /// </summary>
		public int execCount;
		/// <summary>
        /// 
        /// </summary>
        private List<int> m_services;
		/// <summary>
        /// 
        /// </summary>
		public byte interactType;
		/// <summary>
        /// 
        /// </summary>
        private List<bool> m_elevatorFloorActive;
		/// <summary>
        /// 是否是已激活的存档点
        /// </summary>
		public bool isCheckPointActive;
		/// <summary>
        /// 
        /// </summary>
        private List<LevelBuffPOD> m_buffs;
		/// <summary>
        /// 
        /// </summary>
		public int routineActCid;
		/// <summary>
        /// 
        /// </summary>
        private List<int> m_areaEffectCids;
		/// <summary>
        /// 
        /// </summary>
		public int bindEffectRes;
		/// <summary>
        /// 
        /// </summary>
		public int effectBindPoint;
		/// <summary>
        /// 实体绑定的循环音效
        /// </summary>
		public int loopAudio;
		
		
        public List<ushort> tags
        {
            get
            {
                if(m_tags == null)
                {
                    m_tags = new();
                }
                return m_tags;
            }
            private set => m_tags = value;
        }
        public List<ushort> unsafe_tags
        {
        	get => m_tags;
        	set => m_tags = value;
        }
        public List<int> services
        {
            get
            {
                if(m_services == null)
                {
                    m_services = new();
                }
                return m_services;
            }
            private set => m_services = value;
        }
        public List<int> unsafe_services
        {
        	get => m_services;
        	set => m_services = value;
        }
        public List<bool> elevatorFloorActive
        {
            get
            {
                if(m_elevatorFloorActive == null)
                {
                    m_elevatorFloorActive = new();
                }
                return m_elevatorFloorActive;
            }
            private set => m_elevatorFloorActive = value;
        }
        public List<bool> unsafe_elevatorFloorActive
        {
        	get => m_elevatorFloorActive;
        	set => m_elevatorFloorActive = value;
        }
        public List<LevelBuffPOD> buffs
        {
            get
            {
                if(m_buffs == null)
                {
                    m_buffs = new();
                }
                return m_buffs;
            }
            private set => m_buffs = value;
        }
        public List<LevelBuffPOD> unsafe_buffs
        {
        	get => m_buffs;
        	set => m_buffs = value;
        }
        public List<int> areaEffectCids
        {
            get
            {
                if(m_areaEffectCids == null)
                {
                    m_areaEffectCids = new();
                }
                return m_areaEffectCids;
            }
            private set => m_areaEffectCids = value;
        }
        public List<int> unsafe_areaEffectCids
        {
        	get => m_areaEffectCids;
        	set => m_areaEffectCids = value;
        }
		
		/*-- constructors --*/
		public LevelNormalEntityPOD() {}
		public LevelNormalEntityPOD(int mcid, List<ushort> tags, bool isObstacleActive, int execCount, List<int> services, byte interactType, List<bool> elevatorFloorActive, bool isCheckPointActive, List<LevelBuffPOD> buffs, int routineActCid, List<int> areaEffectCids, int bindEffectRes, int effectBindPoint, int loopAudio) {
			this.mcid = mcid;
			this.m_tags = tags;
			this.isObstacleActive = isObstacleActive;
			this.execCount = execCount;
			this.m_services = services;
			this.interactType = interactType;
			this.m_elevatorFloorActive = elevatorFloorActive;
			this.isCheckPointActive = isCheckPointActive;
			this.m_buffs = buffs;
			this.routineActCid = routineActCid;
			this.m_areaEffectCids = areaEffectCids;
			this.bindEffectRes = bindEffectRes;
			this.effectBindPoint = effectBindPoint;
			this.loopAudio = loopAudio;
		}
	      public void Serial(SOutputStream _out) {
            _out.Write_int(mcid);
            _out.Write_list_ushort(m_tags); 
            _out.Write_boolean(isObstacleActive);
            _out.Write_int(execCount);
            _out.Write_list_int(m_services); 
            _out.Write_ubyte(interactType);
            _out.Write_list_boolean(m_elevatorFloorActive); 
            _out.Write_boolean(isCheckPointActive);
            _out.Write_list_pod(m_buffs);
            _out.Write_int(routineActCid);
            _out.Write_list_int(m_areaEffectCids); 
            _out.Write_int(bindEffectRes);
            _out.Write_int(effectBindPoint);
            _out.Write_int(loopAudio);
        }
        
        public void UnSerial(SInputStream _in) {
            if(!_in.HasRemaining()) return;
            mcid = _in.Read_int();
            if(!_in.HasRemaining()) return;
            m_tags = _in.Read_list_ushort();
            if(!_in.HasRemaining()) return;
            isObstacleActive = _in.Read_boolean();
            if(!_in.HasRemaining()) return;
            execCount = _in.Read_int();
            if(!_in.HasRemaining()) return;
            m_services = _in.Read_list_int();
            if(!_in.HasRemaining()) return;
            interactType = _in.Read_ubyte();
            if(!_in.HasRemaining()) return;
            m_elevatorFloorActive = _in.Read_list_boolean();
            if(!_in.HasRemaining()) return;
            isCheckPointActive = _in.Read_boolean();
            if(!_in.HasRemaining()) return;
            m_buffs = _in.Read_list_pod<LevelBuffPOD>(LevelBuffPOD.DynamicFactory);
            if(!_in.HasRemaining()) return;
            routineActCid = _in.Read_int();
            if(!_in.HasRemaining()) return;
            m_areaEffectCids = _in.Read_list_int();
            if(!_in.HasRemaining()) return;
            bindEffectRes = _in.Read_int();
            if(!_in.HasRemaining()) return;
            effectBindPoint = _in.Read_int();
            if(!_in.HasRemaining()) return;
            loopAudio = _in.Read_int();
        }
		
		public LevelNormalEntityPOD Clone() {
            LevelNormalEntityPOD o = DynamicFactory();
            o.mcid = mcid;
            if (m_tags != null) {
                o.m_tags = new (m_tags);
            }
            o.isObstacleActive = isObstacleActive;
            o.execCount = execCount;
            if (m_services != null) {
                o.m_services = new (m_services);
            }
            o.interactType = interactType;
            if (m_elevatorFloorActive != null) {
                o.m_elevatorFloorActive = new (m_elevatorFloorActive);
            }
            o.isCheckPointActive = isCheckPointActive;
            if (m_buffs != null) {
                o.m_buffs = m_buffs.ConvertAll(o => o?.Clone());
            }
            o.routineActCid = routineActCid;
            if (m_areaEffectCids != null) {
                o.m_areaEffectCids = new (m_areaEffectCids);
            }
            o.bindEffectRes = bindEffectRes;
            o.effectBindPoint = effectBindPoint;
            o.loopAudio = loopAudio;
            return o;
        }
        
        public void Clear() {
            mcid = default;
            m_tags = default;
            isObstacleActive = default;
            execCount = default;
            m_services = default;
            interactType = default;
            m_elevatorFloorActive = default;
            isCheckPointActive = default;
            m_buffs = default;
            routineActCid = default;
            m_areaEffectCids = default;
            bindEffectRes = default;
            effectBindPoint = default;
            loopAudio = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "LevelNormalEntityPOD [";
			str += "mcid=";
			str += mcid;
			str += ", tags=";
			str += m_tags.ToString<ushort>();
			str += ", isObstacleActive=";
			str += isObstacleActive;
			str += ", execCount=";
			str += execCount;
			str += ", services=";
			str += m_services.ToString<int>();
			str += ", interactType=";
			str += interactType;
			str += ", elevatorFloorActive=";
			str += m_elevatorFloorActive.ToString<bool>();
			str += ", isCheckPointActive=";
			str += isCheckPointActive;
			str += ", buffs=";
			str += m_buffs.ToString<LevelBuffPOD>();
			str += ", routineActCid=";
			str += routineActCid;
			str += ", areaEffectCids=";
			str += m_areaEffectCids.ToString<int>();
			str += ", bindEffectRes=";
			str += bindEffectRes;
			str += ", effectBindPoint=";
			str += effectBindPoint;
			str += ", loopAudio=";
			str += loopAudio;
			str += "]";
			return str;
		}
		
	}
}